package com.wangnan.currentactivity.extract.datafunction;

import android.util.Log;

import com.wangnan.currentactivity.BaseApplication;
import com.wangnan.currentactivity.Dao.BillList;
import com.wangnan.currentactivity.extract.IData;
import com.wangnan.currentactivity.extract.RecycleDetailsExtract;
import com.wangnan.currentactivity.util.ActivityUtil;
import com.wangnan.currentactivity.util.CustomToast;

//云闪付账单详情
public class 	YSFBillI    extends IData {
	RecycleDetailsExtract a = new RecycleDetailsExtract();
	public YSFBillI(String billtime, String billAmount, String billRmarkse, String billStatus, String billName, String type) {
		super(billtime, billAmount, billRmarkse, billStatus, billName, type);
	}

	@Override
	public void Data() {
		Log.e("zzh", "Data: 开始进入云闪付数据获取" );
		for (int j = 0; j < BaseApplication.userDetailsList.size(); j++) {
			if (BaseApplication.userDetailsList.get(j).getName().equals("订单时间")) {
				billtime = BaseApplication.userDetailsList.get(j + 1).getName(); //云闪付订单时间
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("实付金额（元）")) {
				billAmount = BaseApplication.userDetailsList.get(j + 1).getName(); //云闪付实付金额(元)
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("交易类型")) {
				billRmarkse = BaseApplication.userDetailsList.get(j + 1).getName(); //云闪付交易类型
				billName = BaseApplication.userDetailsList.get(j + 1).getName(); //云闪付名称
			}
			if (BaseApplication.userDetailsList.get(j).getName().equals("订单状态")) {
				billStatus = BaseApplication.userDetailsList.get(j + 1).getName(); //云闪付交易类型
			}
			if (j == BaseApplication.userDetailsList.size() - 1) {

				String textshow = "交易时间 = " + billtime + "\n" +
						"金额 = " + billAmount + "\n" +
						"备注 = " + billRmarkse + "\n" +
						"状态 = " + billStatus + "\n" +
						"名称 = " + billName + "\n";
				CustomToast.showToast(BaseApplication.getGlobalApplication(), textshow);
				Log.e("zzh", "进入云闪付进行添加数据库" + textshow);

				BillList billList = new BillList(ActivityUtil.getUUIDTOLongNew(), type, billtime, billAmount, billRmarkse, billStatus, billName);
				//                          BaseApplication.billListDao.insertBillLists(billList);
				a.writeToTheDatabaseRoom(billList);
			}
		}
	}
}